#ifndef MM_GICONPOINTER
#define MM_GICONPOINTER

#include <QUrl>
extern "C"
{
#include <gio/gio.h>
}

namespace MessagingMenu
{
class GIconPointer
{
private:
    GIcon *icon;
public:
    GIconPointer()
        : icon(NULL)
    {
    }
    GIconPointer(const QUrl &_icon = QUrl())
        : icon(NULL)
    {
        if (_icon.isValid() && _icon.isLocalFile()) {
            QByteArray i = _icon.toLocalFile().toUtf8();
            icon = g_icon_new_for_string(i.data(), NULL);
        }
    }
    GIcon* operator*()
    {
        return icon;
    }
    ~GIconPointer()
    {
        if(icon)
            g_object_unref (icon);
    }
};
}
#endif // MM_GICONPOINTER

